package com.beiing.tianshuai.tianshuai.util;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.beiing.tianshuai.tianshuai.R;
import com.beiing.tianshuai.tianshuai.dongtai.DynamicFragment;
import com.beiing.tianshuai.tianshuai.home.ui.HomeFragment;
import com.beiing.tianshuai.tianshuai.huodong.EventsFragment;
import com.beiing.tianshuai.tianshuai.interest.InterestFragment;
import com.beiing.tianshuai.tianshuai.message.ui.MessageFragment;
import com.beiing.tianshuai.tianshuai.mine.ui.MineFragment;

/**
 * 底部导航栏工厂类 提供图标和名称的匹配
 *
 * @author Yang Jinda
 * @date 2017/7/10
 */

public class FragmentFactory {

    private final String[] mTabTitles = {"首页", "活动", "校园圈", "消息", "我的"};

    public static final int[] TAB_ICON = {
            R.mipmap.home_gray,
            R.drawable.active_gray,
            R.mipmap.dynamic_gray,
            R.mipmap.message_gray,
            R.mipmap.mine_gray
    };

    public static final int[] TAB_ICON_SELECTED = {
            R.mipmap.home_blue,
            R.drawable.active_blue,
            R.mipmap.dynamic_blue,
            R.mipmap.message_blue,
            R.mipmap.mine_blue
    };

    public Fragment[] getFragments() {
        Fragment[] fragments = new Fragment[5];
        fragments[0] = new HomeFragment();
        fragments[1] = new EventsFragment();
        fragments[2] = new DynamicFragment();
        fragments[3] = new MessageFragment();
        fragments[4] = new MineFragment();
        return fragments;
    }

    public View getTabView(Context context, int position) {
        View view = View.inflate(context, R.layout.home_tab_content, null);
        ImageView tabIcon = view.findViewById(R.id.tab_content_image);
        tabIcon.setImageResource(TAB_ICON[position]);
        TextView tabText = view.findViewById(R.id.tab_content_text);
        tabText.setText(mTabTitles[position]);
        return view;
    }
}